
// 水球图
export function liquidFill(data) {
	let liqColor = []; // 波浪颜色
	let bgColor = '';  // 球 背景色
	let bmColor = '';  // 底 发光色
	let statusName = data.status == 0 ? '\n{b|电梯维保中}' : `{c|${data.healthScore}}` + '\n{a|健康分}';
	if (data.healthScore <= 75 && data.healthScore > 60) { // 中
		liqColor = ['#f5a100', 'rgba(255,225,84,0.49)'];
		bgColor = '#FFF2C4';
		bmColor = 'rgb(255, 249, 226,.4)';
	} else if (data.healthScore <= 60) {  // 下
		liqColor = ['#ff3d5a', 'rgba(255,92,61,0.40)'];
		bgColor = '#FFDADD';
		bmColor = 'rgb(255, 235, 238,.4)';
	} else {
		liqColor = ['#5b78e3', 'rgba(160,184,255,0.50)'];
		bgColor = '#E8EEFB';
		bmColor = 'rgb(241, 247, 251,.4)';
	}
	return {
		graphic: {
			elements: [{
				type: 'image',
				z: 999,
				style: {
					image: 'https://erised-fresh.oss-cn-shenzhen.aliyuncs.com/592800/8xlpnRlh2VB0b5a88509b521ef9f87c11f097e133616.png',
					width: 139,
					height: 139,
				},
				left: 'center',
				top: 'center',
			}],
		},
		series: [
			{
				type: 'liquidFill',
				radius: '80%',
				animationEasing: 'linear',
				waveAnimation: false, // 关闭波浪动画
				animationDuration: 0, // 动画完成时间
				animationDurationUpdate: 0,  // 动画交替时间
				center: ['50%', '50%'],
				itemStyle: {
					opacity: 0.95,
					shadowColor: 'rgba(0, 0, 0, 0)',
				},
				data: [
					data.healthScore / 100,  // 健康分
					{
						value: data.healthScore / 100,
						direction: 'left', // 波浪方向
					},
				], // data个数代表波浪数
				backgroundStyle: {
					color: bgColor,
				},
				amplitude: 0,  // 波浪的振幅 '6%' 0即为水平
				// 修改波浪颜色
				color: [
					{
						type: 'linear',
						x: 0,
						y: 0,
						x2: 0,
						y2: 1,
						colorStops: [
							{
								offset: 1,
								color: liqColor[0],
							},
							{
								offset: 0,
								color: liqColor[1],
							},
						],
						globalCoord: false,
					},
				],
				label: {
					normal: {
						formatter: statusName + `\n{b|待处理隐患 ${data.unDisposeCounts || 0}}`,
						rich: {
							a: {
								fontSize: 11,
								align: 'center'
							},
							b: {
								fontSize: 12,
								align: 'center',
								padding: [20, 0, 0, 0],
							},
							c: {
								fontSize: 40,
								align: 'center',
							}
						},
						textStyle: {
							fontSize: 48,
							color: '#fff',
						},
					},
				},
				outline: {
					show: false,
				},
			},
			{
				// 外发光
				type: 'pie',
				radius: ['80%', '90%'],
				center: ['50%', '50%'],
				itemStyle: {
					normal: {
						borderWidth: 20,
						color: bgColor,
					},
				},
				label: {
					show: false,
				},
				data: [100],
			},
			{
				// 底层外发光
				type: 'pie',
				radius: ['80%', '100%'],
				center: ['50%', '50%'],
				itemStyle: {
					normal: {
						borderWidth: 20,
						color: bmColor,
					},
				},
				label: {
					show: false,
				},
				data: [100],
			},
		],
	};
}